package com.example.arouter

import android.content.Context
import android.util.Log
import com.alibaba.android.arouter.facade.Postcard
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.facade.service.DegradeService

/**
 * 全局的降级策略 必须传入上下文
 * */
@Route(path = "/degrade/service")
class GlobeDegradeService : DegradeService {
    private lateinit var mContext: Context
    override fun init(context: Context?) {
        if (context!=null){
            mContext=context
        }
    }

    override fun onLost(context: Context, postcard: Postcard) {
       Log.e("PageDegradeService","Target Page ${postcard.path}not found!")
        postcard.path="/empty/MainActivity"
        postcard.navigation()

    }
}